/// @tags: Dijkstra Bisect
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 1e4 + 1, maxm = 5e4 + 1;

int n, m, b;
int ecnt;
int heads[maxn];

int f[maxn];
long long dis[maxn];

struct Edge {
  int v, nxt, c;
} e[maxm * 2];

inline void add(int u, int v, int c) {
  e[++ecnt].v = v, e[ecnt].c = c, e[ecnt].nxt = heads[u], heads[u] = ecnt;
}

typedef std::pair<int, int> pii;

bool check(int limit) {
  if (f[1] > limit) return false;
  memset(dis, 0x3f, sizeof(dis));
  std::priority_queue<pii, std::vector<pii>, std::greater<pii> > q;
  q.push(std::make_pair(0, 1)), dis[1] = 0;
  while (!q.empty()) {
    int u = q.top().second;
    int d = q.top().first;
    q.pop();
    if (dis[u] != d) continue;
    for (int i = heads[u]; i; i = e[i].nxt) {
      int v = e[i].v;
      if (f[v] <= limit && dis[v] > dis[u] + e[i].c) {
        dis[v] = dis[u] + e[i].c;
        q.push(std::make_pair(dis[v], v));
      }
    }
  }
  return dis[n] <= b;
}

int main() {
  cin >> n >> m >> b;
  for (int i = 1; i <= n; ++i) cin >> f[i];
  for (int i = 1; i <= m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    add(a, b, c), add(b, a, c);
  }
  if (!check(0x3fffffff)) {
    cout << "AFK" << endl;
    return 0;
  }
  int l = 0, r = 1e9;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (check(mid))
      r = mid - 1;
    else
      l = mid + 1;
  }
  cout << l << endl;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P1462 通往奥格瑞玛的道路.in", "r", stdin);
  freopen("P1462 通往奥格瑞玛的道路.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
